#! /usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 22 avr. 2011

@author: nathanael
'''
import unittest
from lxml import etree
import StringIO

from pybible.core import data, find



def get_xml_test():
    return StringIO.StringIO("<root attr='val'>"
                             "<verse>"
                             "du texte par la"
                             "<verse>"
                             "Est encore las"
                             "</verse>"
                             "<verse>"
                             "Toujours La"
                             "</verse>"
                             "</verse>"
                             "</root>")
        




class TestFindStr(unittest.TestCase):
    def setUp(self):
        self.element = data._loadXMLDATA(get_xml_test())
        self.kernel = find.FindKernel(find.RegexPattern('la'))
         
    def test_find(self):
        "Test find tools in easy test case."
        result = self.kernel.find(self.element, wait=True)
        self.assertEqual(len(result.values), 2)
        
        self.assertEqual([i.xpath for i in result.values],
                         ['/root/verse', '/root/verse/verse[1]'])
        

